#ifndef		__CHAOSMATRIX_HPP
#define		__CHAOSMATRIX_HPP

#include "ChaosGlobalDefine.hpp"


namespace Chaos
{
	class ChsVector3;

	class CHAOS_API ChsMatrix
	{
	//--------------------------------------------------------------------------------------------------------------------------------
	public:
		union
		{
					float						m4x4[4][4];
					float						m[16];
			struct
			{
					float						_m11,_m12,_m13,_m14;
					float						_m21,_m22,_m23,_m24;
					float						_m31,_m32,_m33,_m34;
					float						_m41,_m42,_m43,_m44;
				};
		};
												ChsMatrix();
												ChsMatrix( const float * );
												ChsMatrix( const ChsMatrix& );
												ChsMatrix( const float& _11, const float& _12, const float& _13, const float& _14,
															const float& _21, const float& _22, const float& _23, const float& _24,
															const float& _31, const float& _32, const float& _33, const float& _34,
															const float& _41, const float& _42, const float& _43, const float& _44 );

					// binary operators
					//ChsMatrix			operator * ( ChsMatrix & a,ChsMatrix &b);
					//ChsMatrix&		operator *= ( ChsMatrix& );
					ChsMatrix&					operator = ( const ChsMatrix & );
		inline		float*						GetArrary();
					void						Identity();
					void						LookAt(const ChsVector3&,const ChsVector3&,const ChsVector3&);
					void						Ortho(const float w,const float h,const float zn,const float zf);
					void						PerspectiveFov(const float fovy,const float Aspect,const float zn,const float zf);
		
					void						Inverse();
					ChsVector3*					TransformCoord(ChsVector3 * pOut,ChsVector3 * pIn);
					void						Translation(const float& x, const float& y, const float& z);
		static		ChsMatrix*					Multiply(ChsMatrix * pOut, ChsMatrix *pM1,ChsMatrix *pM2);
		
					void						RotateX(float theta);
					void						RotateY(float theta);
					void						RotateZ(float theta);
					
					void						RotateXTo(float theta);
					void						RotateYTo(float theta);
					void						RotateZTo(float theta);
		
	};

	ChsMatrix			operator * ( ChsMatrix & a,ChsMatrix &b);
	ChsMatrix&			operator *= ( ChsMatrix& a,ChsMatrix &b);


	inline float* ChsMatrix::GetArrary()
	{
		return (float*)m;
	};

}

#endif //__CHAOSMATRIX_HPP
